<template>
	<view class="noticeDetail">
		<view class="noticeTitle">
			{{detail.title || ''}}
		</view>
		<view class="noticeTime">{{detail.time}}</view>
		<rich-text :nodes="detailContent"></rich-text>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				detail:'',
				detailContent:'',
				params:{
					id:'',
					data_type:''
				}
			}
		},
		onLoad(options) {
			// if(options.data_type == 1){
			// 	uni.setNavigationBarTitle({
			// 		title:"平台公告"
			// 	})
			// }else if(options.data_type == 2){
			// 	uni.setNavigationBarTitle({
			// 		title:"系统通知"
			// 	})
			// }
			if(options.uid){
				uni.setStorageSync('shareuid',options.uid)
			}
			// this.params.id = options.id;
			// this.params.data_type = options.data_type;
			// this.getNotice()
			this.getHomeInfo()
		},
		methods:{
			// 首页信息
			async getHomeInfo(){
				let res = await uni.$http('POST','home/index');
				if(res.code == 1){
					this.detail = res.data.notice;
					this.detailContent = res.data.notice.content.replaceAll('width: 100%;','width:100%;height:auto;vertical-align:middle;')
					this.detailContent = this.detailContent.replaceAll('<img','<img style="width:100%;height:auto;vertical-align:middle;"')
					if (this.detailContent.indexOf('<p><img') > -1) {
						this.detailContent = this.detailContent.replaceAll('<p><img', '<p style="font-size:0px;"><img')
					}
				}else{
					this.detailContent = '暂无公告';
				}
			},
			async getNotice(){
				let res = await uni.$http('POST','home/noticeDetail',this.params);
				console.log('详情',res);
				if(res.code == 1){
					this.detail = res.data;
					this.detailContent = res.data.content.replaceAll('width: 100%;','width:100%;height:auto;vertical-align:middle;')
					this.detailContent = this.detailContent.replaceAll('<img','<img style="width:100%;height:auto;vertical-align:middle;"')
					if (this.detailContent.indexOf('<p><img') > -1) {
						this.detailContent = this.detailContent.replaceAll('<p><img', '<p style="font-size:0px;"><img')
					}
				}else{
					this.detailContent = '暂无公告'
				}
			}
		},
		// onShareAppMessage(){
		// 	let pages = getCurrentPages()
		// 	let prePage = pages[pages.length - 1];
		// 	return{
		// 		path:`/${prePage.route}?uid=${uni.getStorageSync('uid')}`
		// 	}
		// },
		// onShareTimeline() {
		// 	return{
		// 		query:`uid=${uni.getStorageSync('uid')}`
		// 	}
		// }
	}
</script>

<style lang="scss">
	.noticeDetail{
		color: #000;
		padding: 12rpx 24rpx;
		white-space:normal;
		word-break:break-all;
		word-wrap: break-word;
		.noticeTitle{
			font-size: 34rpx;
			font-weight: 700;
			white-space:normal;
			word-break:break-all;
			word-wrap: break-word;
		}
		.noticeTime{
			color: gray;
			font-size: 24rpx;
			
		}
	}
</style>
<style>
	page{
		background-color: #f7f8fa;
	}
</style>